package com.luanye.enjoy.controller;

import com.luanye.enjoy.dto.PolicySearch;
import com.luanye.enjoy.service.PolicyService;
import com.luanye.enjoy.vo.RespBean;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/policy")
@AllArgsConstructor
public class PolicyController {

    private final PolicyService policyService;


    @GetMapping("/recommend/{pageNum}/{limit}")
    public RespBean getRecommend(@PathVariable("pageNum") Integer pageNum, @PathVariable("limit") Integer limit){
        return policyService.getRecommend(pageNum,limit);
    }

    @GetMapping("/{typeId}/{pageNum}/{limit}")
    public RespBean getPolicyByType(@PathVariable("pageNum") Integer pageNum,
                                    @PathVariable("limit") Integer limit,
                                    @PathVariable("typeId") Integer typeId){
        return policyService.getPolicyByType(pageNum,limit,typeId);
    }
    @GetMapping("/getDetails/{articleId}")
    public RespBean getDetails(@PathVariable("articleId") Long articleId){
        return policyService.getDetails(articleId);
    }
    @PostMapping("/select")
    public RespBean select(@RequestBody PolicySearch policySearch){
        return policyService.selectByKeyword(policySearch.getKeyword());
    }
}
